using System;
using BSDS.Core.Model.Services;

namespace BSDS.Commands.Commands.Implementation
{
    public class DeleteCommand : CommandBase
    {
        private readonly AccountService accountService;
        private readonly string dataSourceName;

        public DeleteCommand(AccountService accountService, string dataSourceName)
        {
            this.accountService = accountService;
            this.dataSourceName = dataSourceName;
        }

        public override CommandResult Execute(ExecutionContext context)
        {
            var sourceInfo = accountService.GetDataSourceInformation(dataSourceName);

            var result = accountService.DeleteDataSource(sourceInfo.AccessId, dataSourceName);

            Console.WriteLine(result);

            return CommandResult.Success();
        }
    }
}